<template>
  <p>{{ global }}</p>
  <button @click="global.age++">age++</button>
  <hr />

  <p>{{ $msg }}</p>

  <hr />
  <button @click="$toast('Hello Liulongbin.', 1500)">展示 Toast 弹窗</button>
  <button @click="showToast">在 JS 中展示 Toast 弹窗</button>
</template>

<script setup>
import { inject, getCurrentInstance } from 'vue'
const global = inject('$global')

const instance = getCurrentInstance()
console.log(instance.appContext.config.globalProperties.$msg)

const showToast = () => {
  const toast = instance.appContext.config.globalProperties.$toast
  toast('你好，刘龙彬。', 2000)
}
</script>

<style scoped></style>
